namespace EyeSoft.Wpf.Facilities.Demo.Configuration
{
	using System.Threading.Tasks;

	using Castle.MicroKernel.Registration;

	using EyeSoft.Mapping;
	using EyeSoft.Messanging;
	using EyeSoft.ServiceLocator.Windsor;
	using EyeSoft.Wpf.Facilities;
	using EyeSoft.Wpf.Facilities.Demo.ViewModels;
	using EyeSoft.Wpf.Facilities.Input;

	public static class ContainerRegister
	{
		private static readonly WindsorDependencyContainer dependencyContainer = new WindsorDependencyContainer();

		static ContainerRegister()
		{
			var kernel = dependencyContainer.Container;

			kernel.Register(Component.For<ILocator>().Instance(dependencyContainer));

			kernel.Register(Component.For<TaskFactory>());

			kernel.Register(Component.For<CommandConvention>().ImplementedBy<DemoCommandConvention>());

			kernel.Register(Component.For<ICommandFactory>().ImplementedBy<CommandFactory>());

			kernel.Register(Component.For<CommandsDiscover>());

			CommandsDiscoverFactory.Set(kernel.Resolve<CommandsDiscover>());

			kernel.Register(Component.For<IMessageBroker>().ImplementedBy<LocalMessageBroker>());

			MessageBroker.Set(kernel.Resolve<IMessageBroker>());

			kernel.Register(Component.For<IMessageBox>().ImplementedBy<LoggingMessageBox>());

			kernel.Register(Component.For<IDialogService>().ImplementedBy<DefaultDialogService>());

			DialogService.Set(kernel.Resolve<IDialogService>());

			kernel.Register(Component.For<IMapper>().ImplementedBy<DemoMapper>());

			kernel.Register(Component.For(typeof(IDisposableFactory<>)).ImplementedBy(typeof(DemoProxyFactory<>)));

			kernel.Register(Component.For(typeof(ServiceFactory<>)));

			kernel.Register(Component.For<MainViewModel>());
			kernel.Register(Component.For<CustomerViewModel>().LifeStyle.Transient);

			ViewModelController.Set(dependencyContainer);
		}

		public static void Initialize()
		{
		}
	}
}